package com.wangsb;

import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @Description: TODO
 * @author: shenbing.wang@hand-china
 * @date: 2021年08月07日 9:38
 */
public class SortReducer extends Reducer<SortBean, NullWritable, SortBean, NullWritable> {

    private SortBean sortBean = new SortBean();
    private long sort = 1;


    @Override
    protected void reduce(SortBean key, Iterable<NullWritable> values, Context context) throws IOException, InterruptedException {
        for (NullWritable value : values) {
            sortBean.setSortFiled(key.getSortFiled());
            sortBean.setSort(sort++);
            context.write(sortBean, NullWritable.get());

        }
    }
}
